package vt.ruminote;

import vt.ruminote.fragment.*;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.e("noteDemo", android.os.Build.VERSION.SDK_INT + ","
                + android.os.Build.VERSION.RELEASE);
        initialParts();
        setContentView(R.layout.main_activity);
    }

    @SuppressLint("NewApi")
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        createMainActionBar(menu);
        return true;
    }

    @SuppressLint("NewApi")
    private void createMainActionBar(Menu menu) {
        MenuItem mnu1 = menu.add(0, 0, 0, "Item 1");
        {
            mnu1.setIcon(R.drawable.action_add);
            mnu1.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        MenuItem mnu2 = menu.add(0, 0, 0, "Item 2");
        {
            mnu2.setIcon(R.drawable.action_search);
            mnu2.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

        MenuItem mnu3 = menu.add(0, 0, 0, "Item 3");
        {
            mnu3.setIcon(R.drawable.content_discard);
            mnu3.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        }

    }

    @SuppressLint("NewApi")
    private void initialParts() {
        ActionBar ab = getActionBar();// enable action bar after v3.0
        ab.setDisplayShowTitleEnabled(false);// disable title display

        FragmentManager fragMgr = getFragmentManager();//get manager
        
        InfoListFragment lstFragment = new InfoListFragment();//get list fragment

        FragmentTransaction ft = fragMgr.beginTransaction();//show
        ft.replace(R.id.frameLayout_main, lstFragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.commit();

    }

}
